-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove anomalies and gaps in handling annotations #13348
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8e06c68
Clean up printing of annotations
odersky 00badaa
Avoid awkward special cases when type mapping AnnotatedTypes
odersky 8434e57
Fix problems handling annotations in dependent function types
odersky d921598
Fix typos
odersky 692cbe5
Fix printing annotations in trees
odersky 046f52a
Fix printing untyped annotations
odersky 00c9adb
test printing of annotations
bishabosha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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 @@ | ||
-- [E007] Type Mismatch Error: tests/neg/annot-printing.scala:5:46 ----------------------------------------------------- | ||
5 |def x: Int @nowarn @main @Foo @Bar("hello") = "abc" // error | ||
| ^^^^^ | ||
| Found: ("abc" : String) | ||
| Required: Int @nowarn() @main @Foo @Bar("hello") | ||
|
||
longer explanation available when compiling with `-explain` |
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 @@ | ||
import scala.annotation.* | ||
class Foo() extends Annotation | ||
class Bar(s: String) extends Annotation | ||
|
||
def x: Int @nowarn @main @Foo @Bar("hello") = "abc" // 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,7 @@ | ||
class C | ||
class ann(x: Any*) extends annotation.Annotation | ||
|
||
def f(y: C, z: C) = | ||
def g(): C @ann(y, z) = ??? | ||
bishabosha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
val ac: ((x: C) => Array[String @ann(x)]) = ??? | ||
val dc = ac(g()) |
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,22 @@ | ||
[[syntax trees at end of typer]] // tests/printing/annot-printing.scala | ||
package <empty> { | ||
import scala.annotation.* | ||
class Foo() extends annotation.Annotation() {} | ||
class Bar(s: String) extends annotation.Annotation() { | ||
private[this] val s: String | ||
} | ||
class Xyz(i: Int) extends annotation.Annotation() { | ||
private[this] val i: Int | ||
} | ||
final lazy module val Xyz: Xyz = new Xyz() | ||
final module class Xyz() extends AnyRef() { this: Xyz.type => | ||
def $lessinit$greater$default$1: Int @uncheckedVariance = 23 | ||
} | ||
final lazy module val annot-printing$package: annot-printing$package = | ||
new annot-printing$package() | ||
final module class annot-printing$package() extends Object() { | ||
this: annot-printing$package.type => | ||
def x: Int @nowarn() @main @Xyz() @Foo @Bar("hello") = ??? | ||
} | ||
} | ||
|
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 @@ | ||
import scala.annotation.* | ||
|
||
class Foo() extends Annotation | ||
class Bar(s: String) extends Annotation | ||
class Xyz(i: Int = 23) extends Annotation | ||
|
||
def x: Int @nowarn @main @Xyz() @Foo @Bar("hello") = ??? |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with these changes
-Xprint:parser
will only show<none>
where the class name should beThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in 3.1.0-RC1 we still show the correct class names with
-Xprint:parser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Is there an easy way to write a printing test to guard against regressions for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the
PrintingTest
can be modified to add cases that print at parser instead:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@odersky I have added tests to
PrintingTest
in latest commit