From 34532d7e92b8ed2a9411260007fcfcc00f377ccc Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Mon, 17 Feb 2014 22:05:14 +0100 Subject: tests for SI-8300 Highlights the dilemma with rich type members in the cake that no longer exists. One used to have to choose between overloading or patmat/extmeth friendliness, but couldn't have both. Thanks to retronym we can have it all. --- test/files/neg/t8300-overloading.check | 7 +++++++ test/files/neg/t8300-overloading.scala | 16 ++++++++++++++++ test/files/pos/t8300-conversions-a.scala | 23 +++++++++++++++++++++++ test/files/pos/t8300-conversions-b.scala | 23 +++++++++++++++++++++++ test/files/pos/t8300-overloading.scala | 16 ++++++++++++++++ test/files/pos/t8300-patmat-a.scala | 20 ++++++++++++++++++++ test/files/pos/t8300-patmat-b.scala | 20 ++++++++++++++++++++ 7 files changed, 125 insertions(+) create mode 100644 test/files/neg/t8300-overloading.check create mode 100644 test/files/neg/t8300-overloading.scala create mode 100644 test/files/pos/t8300-conversions-a.scala create mode 100644 test/files/pos/t8300-conversions-b.scala create mode 100644 test/files/pos/t8300-overloading.scala create mode 100644 test/files/pos/t8300-patmat-a.scala create mode 100644 test/files/pos/t8300-patmat-b.scala (limited to 'test/files') diff --git a/test/files/neg/t8300-overloading.check b/test/files/neg/t8300-overloading.check new file mode 100644 index 0000000000..edd34d44bd --- /dev/null +++ b/test/files/neg/t8300-overloading.check @@ -0,0 +1,7 @@ +t8300-overloading.scala:15: error: double definition: +def foo(name: Test.u.Name): Nothing at line 14 and +def foo(name: Test.u.TermName): Nothing at line 15 +have same type after erasure: (name: Universe#NameApi)Nothing + def foo(name: TermName) = ??? + ^ +one error found diff --git a/test/files/neg/t8300-overloading.scala b/test/files/neg/t8300-overloading.scala new file mode 100644 index 0000000000..eb393155a0 --- /dev/null +++ b/test/files/neg/t8300-overloading.scala @@ -0,0 +1,16 @@ +// cf. pos/t8300-overloading.scala +trait Universe { + type Name >: Null <: AnyRef with NameApi + trait NameApi + + type TermName >: Null <: Name with TermNameApi + trait TermNameApi extends NameApi +} + +object Test extends App { + val u: Universe = ??? + import u._ + + def foo(name: Name) = ??? + def foo(name: TermName) = ??? +} \ No newline at end of file diff --git a/test/files/pos/t8300-conversions-a.scala b/test/files/pos/t8300-conversions-a.scala new file mode 100644 index 0000000000..248a8b73b2 --- /dev/null +++ b/test/files/pos/t8300-conversions-a.scala @@ -0,0 +1,23 @@ +// cf. pos/t8300-conversions-b.scala +trait Universe { + type Symbol >: Null <: AnyRef with SymbolApi + trait SymbolApi + + type TypeSymbol >: Null <: Symbol with TypeSymbolApi + trait TypeSymbolApi extends SymbolApi + + type FreeTypeSymbol >: Null <: TypeSymbol with FreeTypeSymbolApi + trait FreeTypeSymbolApi extends TypeSymbolApi + + implicit class CompatibleSymbol(sym: Symbol) { + def asFreeType: FreeTypeSymbol = ??? + } +} + +object Test extends App { + val u: Universe = ??? + import u._ + + val sym: Symbol = ??? + sym.asFreeType +} \ No newline at end of file diff --git a/test/files/pos/t8300-conversions-b.scala b/test/files/pos/t8300-conversions-b.scala new file mode 100644 index 0000000000..0524ee3683 --- /dev/null +++ b/test/files/pos/t8300-conversions-b.scala @@ -0,0 +1,23 @@ +// cf. pos/t8300-conversions-a.scala +trait Universe { + type Symbol >: Null <: AnyRef with SymbolApi + trait SymbolApi + + type TypeSymbol >: Null <: TypeSymbolApi with Symbol + trait TypeSymbolApi extends SymbolApi + + type FreeTypeSymbol >: Null <: FreeTypeSymbolApi with TypeSymbol + trait FreeTypeSymbolApi extends TypeSymbolApi + + implicit class CompatibleSymbol(sym: Symbol) { + def asFreeType: FreeTypeSymbol = ??? + } +} + +object Test extends App { + val u: Universe = ??? + import u._ + + val sym: Symbol = ??? + sym.asFreeType +} \ No newline at end of file diff --git a/test/files/pos/t8300-overloading.scala b/test/files/pos/t8300-overloading.scala new file mode 100644 index 0000000000..ae9699ab86 --- /dev/null +++ b/test/files/pos/t8300-overloading.scala @@ -0,0 +1,16 @@ +// cf. neg/t8300-overloading.scala +trait Universe { + type Name >: Null <: AnyRef with NameApi + trait NameApi + + type TermName >: Null <: TermNameApi with Name + trait TermNameApi extends NameApi +} + +object Test extends App { + val u: Universe = ??? + import u._ + + def foo(name: Name) = ??? + def foo(name: TermName) = ??? +} \ No newline at end of file diff --git a/test/files/pos/t8300-patmat-a.scala b/test/files/pos/t8300-patmat-a.scala new file mode 100644 index 0000000000..4421c0a15e --- /dev/null +++ b/test/files/pos/t8300-patmat-a.scala @@ -0,0 +1,20 @@ +// cf. pos/t8300-patmat-b.scala +trait Universe { + type Name >: Null <: AnyRef with NameApi + trait NameApi + + type TermName >: Null <: Name with TermNameApi + trait TermNameApi extends NameApi +} + +object Test extends App { + val u: Universe = ??? + import u._ + + locally { + val ScalaName: TermName = ??? + ??? match { + case ScalaName => ??? + } + } +} \ No newline at end of file diff --git a/test/files/pos/t8300-patmat-b.scala b/test/files/pos/t8300-patmat-b.scala new file mode 100644 index 0000000000..c01aeb912d --- /dev/null +++ b/test/files/pos/t8300-patmat-b.scala @@ -0,0 +1,20 @@ +// cf. pos/t8300-patmat-a.scala +trait Universe { + type Name >: Null <: AnyRef with NameApi + trait NameApi + + type TermName >: Null <: TermNameApi with Name + trait TermNameApi extends NameApi +} + +object Test extends App { + val u: Universe = ??? + import u._ + + locally { + val ScalaName: TermName = ??? + ??? match { + case ScalaName => ??? + } + } +} \ No newline at end of file -- cgit v1.2.3