-
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.
Allow New, Select, Block, ValDef, DefDef, Closure and EmptyTree
And use a TreeMap for the annotation check
- Loading branch information
Showing
15 changed files
with
129 additions
and
107 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 |
---|---|---|
@@ -1,48 +1,24 @@ | ||
-- Error: tests/neg/annot-invalid.scala:4:21 --------------------------------------------------------------------------- | ||
4 | val x1: Int @annot(new Object {}) = 0 // error | ||
| ^^^^^^^^^^^^^ | ||
| Implementation restriction: not a valid annotation argument. | ||
| Argument: { | ||
| final class $anon() extends Object() {} | ||
| new $anon():Object | ||
| } | ||
| Type: Object | ||
-- Error: tests/neg/annot-invalid.scala:5:21 --------------------------------------------------------------------------- | ||
5 | val x2: Int @annot({val x = 1}) = 0 // error | ||
| ^^^^^^^^^^^ | ||
| Implementation restriction: not a valid annotation argument. | ||
| Argument: { | ||
| val x: Int = 1 | ||
| () | ||
| } | ||
| Type: Unit | ||
-- Error: tests/neg/annot-invalid.scala:6:21 --------------------------------------------------------------------------- | ||
6 | val x3: Int @annot((x: Int) => x) = 0 // error | ||
| ^^^^^^^^^^^^^ | ||
| Implementation restriction: not a valid annotation argument. | ||
| Argument: (x: Int) => x | ||
| Type: Int => Int | ||
-- Error: tests/neg/annot-invalid.scala:8:9 ---------------------------------------------------------------------------- | ||
8 | @annot(new Object {}) val y1: Int = 0 // error | ||
| Implementation restriction: this tree cannot be used in an annotation. | ||
| Tree: final class $anon() extends Object() {} | ||
| Type: Object {...} | ||
-- Error: tests/neg/annot-invalid.scala:5:28 --------------------------------------------------------------------------- | ||
5 | val x2: Int @annot({class C}) = 0 // error | ||
| ^^^^^^^ | ||
| Implementation restriction: this tree cannot be used in an annotation. | ||
| Tree: class C() extends Object() {} | ||
| Type: C | ||
-- Error: tests/neg/annot-invalid.scala:7:9 ---------------------------------------------------------------------------- | ||
7 | @annot(new Object {}) val y1: Int = 0 // error | ||
| ^^^^^^^^^^^^^ | ||
| Implementation restriction: not a valid annotation argument. | ||
| Argument: { | ||
| final class $anon() extends Object() {} | ||
| new $anon():Object | ||
| } | ||
| Type: Object | ||
-- Error: tests/neg/annot-invalid.scala:9:9 ---------------------------------------------------------------------------- | ||
9 | @annot({val x = 1}) val y2: Int = 0 // error | ||
| ^^^^^^^^^^^ | ||
| Implementation restriction: not a valid annotation argument. | ||
| Argument: { | ||
| val x: Int = 1 | ||
| () | ||
| } | ||
| Type: Unit | ||
-- Error: tests/neg/annot-invalid.scala:10:9 --------------------------------------------------------------------------- | ||
10 | @annot((x: Int) => x) val y3: Int = 0 // error | ||
| ^^^^^^^^^^^^^ | ||
| Implementation restriction: not a valid annotation argument. | ||
| Argument: (x: Int) => x | ||
| Type: Int => Int | ||
| Implementation restriction: this tree cannot be used in an annotation. | ||
| Tree: final class $anon() extends Object() {} | ||
| Type: Object {...} | ||
-- Error: tests/neg/annot-invalid.scala:8:16 --------------------------------------------------------------------------- | ||
8 | @annot({class C}) val y2: Int = 0 // error | ||
| ^^^^^^^ | ||
| Implementation restriction: this tree cannot be used in an annotation. | ||
| Tree: class C() extends Object() {} | ||
| Type: C |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 @@ | ||
import scala.annotation.Annotation | ||
class myRefined(f: ? => Boolean) extends Annotation | ||
|
||
def test(axes: Int) = true | ||
|
||
trait Tensor: | ||
def mean(axes: Int): Int @myRefined(_ => test(axes)) | ||
|
||
class TensorImpl() extends Tensor: | ||
def mean(axes: Int) = ??? |
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 |
---|---|---|
|
@@ -13,4 +13,3 @@ def f2(t: Tuple) = | |
t match | ||
case _: (t *: ts) => () | ||
case _ => () | ||
|
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,15 @@ | ||
import scala.annotation.Annotation | ||
|
||
class AnAnnotation(function: Int => String) extends Annotation | ||
|
||
@AnAnnotation(_.toString) | ||
val a = 1 | ||
@AnAnnotation(_.toString.length.toString) | ||
val b = 2 | ||
|
||
def test = | ||
@AnAnnotation(_.toString) | ||
val a = 1 | ||
@AnAnnotation(_.toString.length.toString) | ||
val b = 2 | ||
a + b |
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,2 @@ | ||
class A(a: Any) extends annotation.StaticAnnotation | ||
@A({val x = 0}) trait B |
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,2 @@ | ||
class A(a: Any) extends annotation.StaticAnnotation | ||
@A({def x = 0}) trait B |
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,19 @@ | ||
[[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(() => Test.y) = 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(() => x) = 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) |