Skip to content

Commit e850a99

Browse files
committed
Test other forms of singleton types.
Tested are now other numeric values, strings, booleans, which are all legal singleton types.
1 parent 289e273 commit e850a99

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

test/dotc/tests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class tests extends CompilerTest {
146146
@Test def neg_instantiateAbstract = compileFile(negDir, "instantiateAbstract", xerrors = 8)
147147
@Test def neg_selfInheritance = compileFile(negDir, "selfInheritance", xerrors = 6)
148148
@Test def neg_selfreq = compileFile(negDir, "selfreq", xerrors = 4)
149-
@Test def neg_singletons = compileFile(negDir, "singletons", xerrors = 2)
149+
@Test def neg_singletons = compileFile(negDir, "singletons", xerrors = 4)
150150
@Test def neg_shadowedImplicits = compileFile(negDir, "arrayclone-new", xerrors = 2)
151151
@Test def neg_traitParamsTyper = compileFile(negDir, "traitParamsTyper", xerrors = 5)
152152
@Test def neg_traitParamsMixin = compileFile(negDir, "traitParamsMixin", xerrors = 2)

tests/pos/singletons.scala

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,17 @@ object Test {
1212
val b: 2 = a
1313

1414
def f: 3 = 3
15-
val c = f
15+
final val c = f
1616

17+
val dc: 3.0 = 3.0
18+
final val dc1 = dc
19+
val fc: 3.0f = 3.0f
20+
final val fc1 = fc
21+
22+
val t: true = true
23+
24+
val str: "" = ""
25+
final val str2 = str
1726
}
1827
/* To do: test that after erasure we have generated code like this:
1928
*
@@ -34,7 +43,14 @@ package <empty> {
3443
}
3544
<accessor> def b(): Int = 2
3645
def f(): Int = 3
37-
<accessor> def c(): Int = Test.f()
46+
final <accessor> def c(): Int = Test.f()
47+
<accessor> def dc(): Double = 3.0
48+
final <accessor> def dc1(): Double = 3.0
49+
<accessor> def fc(): Float = 3.0
50+
final <accessor> def fc1(): Float = 3.0
51+
<accessor> def t(): Boolean = true
52+
<accessor> def str(): String = ""
53+
final <accessor> def str2(): String = ""
3854
}
3955
}
4056
*/

0 commit comments

Comments
 (0)