-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f483b16
commit 74b629f
Showing
17 changed files
with
185 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import reflect.Selectable.reflectiveSelectable | ||
|
||
class C(var x: Int) { | ||
def foo(): Int = 20 | ||
} | ||
|
||
class D(var y: Int) { | ||
def foo(): Int = A.m | ||
} | ||
|
||
class Box(var value: { | ||
def foo(): Int | ||
}) | ||
|
||
object A: | ||
val box1: Box = new Box(new C(5)) | ||
val box2: Box = new Box(new D(10)) | ||
val m: Int = box1.value.foo() // error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class X { | ||
def foo(): Int = 10 | ||
} | ||
|
||
object A { | ||
var a: X = new X() | ||
} | ||
|
||
object B { | ||
val b: Int = A.a.foo() | ||
} | ||
|
||
class Y extends X { | ||
override def foo() = C.c | ||
} | ||
|
||
object C { | ||
val c: Int = B.b | ||
} | ||
|
||
def main = { | ||
A.a = new Y(); C // error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
case class Foo(name: String) | ||
|
||
object O: | ||
val a = Foo("Apple") | ||
val b = Foo("Banana") | ||
val c = Foo("Cherry") | ||
|
||
object Foo: | ||
val all: List[Foo] = List(O.a, O.b, O.c) // error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
object NameKinds: | ||
abstract class NameKind(val tag: Int): | ||
class Info | ||
class QualifiedNameKind(tag: Int, val separator: String) extends NameKind(tag): | ||
qualifiedNameKinds(tag) = this // error | ||
|
||
|
||
val MAX_TAG = 8 | ||
val qualifiedNameKinds = new Array[QualifiedNameKind](MAX_TAG) | ||
|
||
val QualifiedName: QualifiedNameKind = new QualifiedNameKind(0, ".") | ||
val FlatName: QualifiedNameKind = new QualifiedNameKind(1, "$") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Box(var value: Int) | ||
|
||
object A: | ||
val box: Box = new Box(4) | ||
|
||
object B: | ||
val boxB: Box = new Box(5) | ||
val boxA: Box = A.box | ||
val m: Int = boxB.value | ||
val n: Int = boxA.value // error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
object A: | ||
class Box(var value: Int) { | ||
val initial: Int = value | ||
} | ||
val box: Box = new Box(0) | ||
|
||
object B: | ||
val box: A.Box = A.box | ||
val a: Int = box.initial | ||
val b: Int = box.value // error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
object A: | ||
class Box(var value: Int) | ||
val box: Box = new Box(0) | ||
|
||
object B: | ||
val boxes: Array[A.Box] = Array(A.box) | ||
val box: A.Box = boxes(0) | ||
val x: Int = box.value // error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Box(var value: Int) | ||
|
||
object A: | ||
val box: Box = new Box(4) | ||
|
||
object B: | ||
val boxB: Box = new Box(5) | ||
val boxA: Box = A.box | ||
val m: Int = boxB.value | ||
val n: Int = boxA.value // error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
object Names: | ||
class Name(val start: Int, val length: Int) | ||
var chrs: Array[Char] = new Array[Char](0x20000) | ||
def name(s: String): Name = Name(0, chrs.length) // error | ||
|
||
object StdNames: | ||
val AnyRef: Names.Name = Names.name("AnyRef") | ||
val Array: Names.Name = Names.name("Array") | ||
val List: Names.Name = Names.name("List") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class SourceFile | ||
|
||
object Contexts: | ||
val NoContext: Context = new Context | ||
class Context: | ||
private var _source: SourceFile = null | ||
final def source: SourceFile = _source // error | ||
def setSource(source: SourceFile) = { | ||
this._source = source | ||
} | ||
|
||
object Implicits: | ||
import Contexts.* | ||
case class SearchFailure(tag: Int, source: SourceFile) | ||
val NoMatchingFailure: SearchFailure = SearchFailure(1, NoContext.source) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
object Positioned: | ||
var debug: Boolean = false | ||
var debugId = Int.MinValue | ||
var nextId: Int = 0 | ||
|
||
abstract class Positioned: | ||
if (Positioned.debug) { // error | ||
println("do debugging") | ||
} | ||
|
||
object Trees: | ||
class Tree extends Positioned | ||
val emptyTree = new Tree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
object Stats { | ||
var monitored: Boolean = false | ||
} | ||
|
||
class UncachedGroundType { | ||
if (Stats.monitored) println("record stats") // error | ||
} | ||
|
||
class LazyType extends UncachedGroundType | ||
|
||
object NoCompleter extends LazyType |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
object Names: | ||
val ctorString = "<init>" | ||
val ctorName: MethodName = MethodName.apply(ctorString) | ||
|
||
class MethodName(encoded: String) | ||
object MethodName: | ||
val ctor: MethodName = new MethodName(Names.ctorString) // error | ||
def apply(name: String): MethodName = new MethodName(name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class A(x: Int) { | ||
def foo(): Int = B.m | ||
} | ||
|
||
object B: | ||
val m: Int = 20 | ||
val n: Int = new A(10).foo() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
object A: | ||
val a: Int = 10 | ||
val b: Int = 20 | ||
|
||
object B: | ||
var n: Int = A.a * A.b | ||
|
||
@main def entry() = println(B.n) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class A(val a: A) | ||
|
||
object B: | ||
val a: A = loop(ofA()) | ||
def ofA(): A = ofA().a | ||
def loop(a: A): A = loop(new A(a)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
object Trees: | ||
private var counter = 0 | ||
class Tree { | ||
counter += 1 | ||
} | ||
|
||
class EmptyTree extends Tree | ||
val theEmptyTree = new EmptyTree |