-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implement @alpha annotation #6597
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c4604fa
Implement @alpha annotation
odersky 1e17425
Don't cache erasedName
odersky ebb1195
Allow @alpha on types
odersky d5f5ae5
Deprecation warnings for operators without alpha
odersky dd221ae
Address review comments
odersky 97a8a37
fix tests
odersky 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 @@ | ||
// Compile with -strict -Xfatal-warnings -deprecation | ||
import scala.annotation.alpha | ||
class & { // error | ||
|
||
@alpha("op") def *(x: Int): Int = ??? // OK | ||
def / (x: Int): Int // error | ||
val frozen_& : Int = ??? // error | ||
object some_??? // error | ||
} |
This file contains hidden or 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,14 @@ | ||
|
||
import annotation.alpha | ||
|
||
class Gamma { | ||
|
||
def foo2() = { | ||
def bar = 1 | ||
@alpha("bar") def baz = 2 // error: @alpha annotation clashes | ||
|
||
@alpha("bam") def x1 = 0 | ||
@alpha("bam") def y1 = 0 // error: @alpha annotation clashes | ||
|
||
} | ||
} |
This file contains hidden or 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 @@ | ||
|
||
import annotation.alpha | ||
|
||
class Gamma { | ||
|
||
def foo: Int = 1 | ||
|
||
} | ||
|
||
class Delta extends Gamma { // error: name clash | ||
@alpha("foo") def bar: Int = 1 | ||
} |
This file contains hidden or 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 @@ | ||
// Java | ||
public class B_1 extends A_1 { | ||
public int bar() { | ||
return 2; | ||
} | ||
} |
This file contains hidden or 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,4 @@ | ||
import annotation.alpha | ||
class C extends B_1 { // error: Name clash between defined and inherited member | ||
@alpha("bar") override def foo(): Int = 3 | ||
} |
This file contains hidden or 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 annotation.alpha | ||
class D extends B_1 { | ||
@alpha("bar") def foo(): Int = 3 // error: needs override | ||
} | ||
class E extends B_1 { | ||
@alpha("baz") override def bar(): Int = 3 // error: cannot have an @alpha annotation since external names would be different | ||
} |
This file contains hidden or 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 @@ | ||
import annotation.alpha | ||
|
||
|
||
abstract class Alpha[T] { | ||
|
||
def foo() = 1 | ||
|
||
@alpha("bar") def foo(x: T): T | ||
|
||
@alpha("append") def ++ (xs: Alpha[T]): Alpha[T] = this | ||
|
||
} | ||
|
||
class Beta extends Alpha[String] { | ||
|
||
@alpha("foo1") override def foo() = 1 // error | ||
|
||
@alpha("baz") def foo(x: String): String = x ++ x // error | ||
|
||
override def ++ (xs: Alpha[String]): Alpha[String] = this // error | ||
|
||
} |
This file contains hidden or 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,20 @@ | ||
|
||
import annotation.alpha | ||
|
||
class Gamma { | ||
|
||
val v = 1 | ||
@alpha("v") val w = 2 // error: double definition | ||
|
||
} | ||
// Error when overloading polymorphic and non-polymorphic methods | ||
class Test19 { | ||
def foo[T <: Int](x: T): T = x | ||
def foo(x: Int): Int = x // error | ||
} | ||
|
||
// Error when overloading polymorphic methods | ||
class Test20 { | ||
def foo[T <: Int](x: T): T = x | ||
def foo[S <: Int, T <: Int](x: S): T = ??? // error | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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,5 @@ | ||
// Scala | ||
import annotation.alpha | ||
class A_1 { | ||
@alpha("bar") def foo(): Int = 1 | ||
} |
This file contains hidden or 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 @@ | ||
// Java | ||
public class B_2 extends A_1 { | ||
@Override | ||
public int bar() { | ||
return 2; | ||
} | ||
} |
This file contains hidden or 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 @@ | ||
import annotation.alpha | ||
|
||
object Test { | ||
|
||
def foo() = 1 | ||
|
||
@alpha("bar") def foo(x: Int) = 2 | ||
} |
This file contains hidden or 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 @@ | ||
|
||
package alpha; | ||
|
||
public class Test_2 { | ||
|
||
public static void main(String[] args) { | ||
Alpha<String> a = new Bar(); | ||
assert a.foo() == 1; | ||
assert a.bar("a").equals("aa"); | ||
Alpha<String> aa = a.append(a); | ||
} | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.