-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Fix mapping of annotations containing defs
- Loading branch information
Showing
8 changed files
with
94 additions
and
5 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
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
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 qualified[T](f: T => Boolean) extends annotation.StaticAnnotation | ||
|
||
class Box[T](val x: T) | ||
class Box2(val x: Int) | ||
|
||
class A(a: String @qualified((x: Int) => Box(3).x == 3)) // crash | ||
class A2(a2: String @qualified((x: Int) => Box2(3).x == 3)) // works |
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 @@ | ||
class qualified[T](predicate: T => Boolean) extends annotation.StaticAnnotation | ||
|
||
class EqualPair(val x: Int, val y: Int @qualified[Int](it => it == x)) | ||
|
||
@main def main = | ||
val p = EqualPair(42, 42) | ||
val y = p.y | ||
println(42) |
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,16 @@ | ||
[[syntax trees at end of typer]] // tests/printing/annot-18064.scala | ||
package <empty> { | ||
class myAnnot[T >: Nothing <: Any]() extends annotation.Annotation() { | ||
T | ||
} | ||
trait Tensor[T >: Nothing <: Any]() extends Object { | ||
T | ||
def add: Tensor[Tensor.this.T] @myAnnot[T] | ||
} | ||
class TensorImpl[A >: Nothing <: Any]() extends Object(), Tensor[ | ||
TensorImpl.this.A] { | ||
A | ||
def add: Tensor[A] @myAnnot[A] = this | ||
} | ||
} | ||
|
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 myAnnot[T]() extends annotation.Annotation | ||
|
||
trait Tensor[T]: | ||
def add: Tensor[T] @myAnnot[T]() | ||
|
||
class TensorImpl[A]() extends Tensor[A]: | ||
def add /* : Tensor[A] @myAnnot[A] */ = this |
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,33 @@ | ||
[[syntax trees at end of typer]] // tests/printing/annot-19846b.scala | ||
package <empty> { | ||
class lambdaAnnot(g: () => Int) extends scala.annotation.Annotation(), | ||
annotation.StaticAnnotation { | ||
private[this] val g: () => Int | ||
} | ||
final lazy module val Test: Test = new Test() | ||
final module class Test() extends Object() { this: Test.type => | ||
val y: Int = ??? | ||
val z: | ||
Int @lambdaAnnot( | ||
{ | ||
def $anonfun(): Int = Test.y | ||
closure($anonfun) | ||
} | ||
) | ||
= f(Test.y) | ||
} | ||
final lazy module val annot-19846b$package: annot-19846b$package = | ||
new annot-19846b$package() | ||
final module class annot-19846b$package() extends Object() { | ||
this: annot-19846b$package.type => | ||
def f(x: Int): | ||
Int @lambdaAnnot( | ||
{ | ||
def $anonfun(): Int = x | ||
closure($anonfun) | ||
} | ||
) | ||
= x | ||
} | ||
} | ||
|
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 lambdaAnnot(g: () => Int) extends annotation.StaticAnnotation | ||
|
||
def f(x: Int): Int @lambdaAnnot(() => x) = x | ||
|
||
object Test: | ||
val y: Int = ??? | ||
val z /* : Int @lambdaAnnot(() => y) */ = f(y) |