diff options
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/neg/names-defaults-neg.check | 12 | ||||
-rw-r--r-- | test/files/neg/t5044.check | 4 | ||||
-rw-r--r-- | test/files/neg/t5091.check | 4 | ||||
-rw-r--r-- | test/files/neg/t8463.check | 19 | ||||
-rw-r--r-- | test/files/neg/t8841.check | 9 | ||||
-rw-r--r-- | test/files/neg/t8841.scala | 15 | ||||
-rw-r--r-- | test/files/neg/t9041.check | 4 | ||||
-rw-r--r-- | test/files/neg/t9041.scala | 17 | ||||
-rw-r--r-- | test/files/pos/t9123.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t9123.scala | 10 | ||||
-rw-r--r-- | test/files/run/t9097.scala | 34 |
11 files changed, 118 insertions, 11 deletions
diff --git a/test/files/neg/names-defaults-neg.check b/test/files/neg/names-defaults-neg.check index 20ddd55f1f..2db24b6f32 100644 --- a/test/files/neg/names-defaults-neg.check +++ b/test/files/neg/names-defaults-neg.check @@ -151,15 +151,15 @@ names-defaults-neg.scala:144: error: variable definition needs type because 'x' names-defaults-neg.scala:147: error: variable definition needs type because 'x' is used as a named argument in its body. object t6 { var x = t.f(x = 1) } ^ -names-defaults-neg.scala:147: warning: type-checking the invocation of method f checks if the named argument expression 'x = ...' is a valid assignment -in the current scope. The resulting type inference error (see above) can be fixed by providing an explicit type in the local definition for x. +names-defaults-neg.scala:147: warning: failed to determine if 'x = ...' is a named argument or an assignment expression. +an explicit type is required for the definition mentioned in the error message above. object t6 { var x = t.f(x = 1) } ^ names-defaults-neg.scala:150: error: variable definition needs type because 'x' is used as a named argument in its body. class t9 { var x = t.f(x = 1) } ^ -names-defaults-neg.scala:150: warning: type-checking the invocation of method f checks if the named argument expression 'x = ...' is a valid assignment -in the current scope. The resulting type inference error (see above) can be fixed by providing an explicit type in the local definition for x. +names-defaults-neg.scala:150: warning: failed to determine if 'x = ...' is a named argument or an assignment expression. +an explicit type is required for the definition mentioned in the error message above. class t9 { var x = t.f(x = 1) } ^ names-defaults-neg.scala:164: error: variable definition needs type because 'x' is used as a named argument in its body. @@ -174,8 +174,8 @@ names-defaults-neg.scala:170: error: reference to x is ambiguous; it is both a m names-defaults-neg.scala:177: error: variable definition needs type because 'x' is used as a named argument in its body. class u15 { var x = u.f(x = 1) } ^ -names-defaults-neg.scala:177: warning: type-checking the invocation of method f checks if the named argument expression 'x = ...' is a valid assignment -in the current scope. The resulting type inference error (see above) can be fixed by providing an explicit type in the local definition for x. +names-defaults-neg.scala:177: warning: failed to determine if 'x = ...' is a named argument or an assignment expression. +an explicit type is required for the definition mentioned in the error message above. class u15 { var x = u.f(x = 1) } ^ names-defaults-neg.scala:180: error: reference to x is ambiguous; it is both a method parameter and a variable in scope. diff --git a/test/files/neg/t5044.check b/test/files/neg/t5044.check index 197da2a4e8..dc3708123f 100644 --- a/test/files/neg/t5044.check +++ b/test/files/neg/t5044.check @@ -1,8 +1,8 @@ t5044.scala:7: error: recursive value a needs type val id = m(a) ^ -t5044.scala:6: warning: type-checking the invocation of method foo checks if the named argument expression 'id = ...' is a valid assignment -in the current scope. The resulting type inference error (see above) can be fixed by providing an explicit type in the local definition for id. +t5044.scala:6: warning: failed to determine if 'id = ...' is a named argument or an assignment expression. +an explicit type is required for the definition mentioned in the error message above. val a = foo(id = 1) ^ one warning found diff --git a/test/files/neg/t5091.check b/test/files/neg/t5091.check index abd24e3145..156f695f41 100644 --- a/test/files/neg/t5091.check +++ b/test/files/neg/t5091.check @@ -1,8 +1,8 @@ t5091.scala:8: error: recursive value xxx needs type val param = bar(xxx) ^ -t5091.scala:7: warning: type-checking the invocation of method foo checks if the named argument expression 'param = ...' is a valid assignment -in the current scope. The resulting type inference error (see above) can be fixed by providing an explicit type in the local definition for param. +t5091.scala:7: warning: failed to determine if 'param = ...' is a named argument or an assignment expression. +an explicit type is required for the definition mentioned in the error message above. val xxx = foo(param = null) ^ one warning found diff --git a/test/files/neg/t8463.check b/test/files/neg/t8463.check index 1a3eea2870..9aaacf8391 100644 --- a/test/files/neg/t8463.check +++ b/test/files/neg/t8463.check @@ -7,4 +7,21 @@ Note that implicit conversions are not applicable because they are ambiguous: are possible conversion functions from Long to ?T[Long] insertCell(Foo(5)) ^ -one error found +t8463.scala:5: error: no type parameters for method apply: (activity: T[Long])Test.Foo[T] in object Foo exist so that it can be applied to arguments (Long) + --- because --- +argument expression's type is not compatible with formal parameter type; + found : Long + required: ?T[Long] + insertCell(Foo(5)) + ^ +t8463.scala:5: error: type mismatch; + found : Long(5L) + required: T[Long] + insertCell(Foo(5)) + ^ +t8463.scala:5: error: type mismatch; + found : Test.Foo[T] + required: Test.Foo[Test.Cell] + insertCell(Foo(5)) + ^ +four errors found diff --git a/test/files/neg/t8841.check b/test/files/neg/t8841.check new file mode 100644 index 0000000000..ad525dc3f8 --- /dev/null +++ b/test/files/neg/t8841.check @@ -0,0 +1,9 @@ +t8841.scala:13: error: recursive value c needs type + val ambiguousName = c.ambiguousName + ^ +t8841.scala:12: warning: failed to determine if 'ambiguousName = ...' is a named argument or an assignment expression. +an explicit type is required for the definition mentioned in the error message above. + val c = new Cell(ambiguousName = Some("bla")) + ^ +one warning found +one error found diff --git a/test/files/neg/t8841.scala b/test/files/neg/t8841.scala new file mode 100644 index 0000000000..80430d997e --- /dev/null +++ b/test/files/neg/t8841.scala @@ -0,0 +1,15 @@ +class Cell(val ambiguousName: Option[String]) + +class Test { + def wrap(f: Any): Nothing = ??? + + wrap { + // the namer for these two ValDefs is created when typing the argument expression + // of wrap. This happens to be in a silent context (tryTypedApply). Therefore, the + // cyclic reference will not be thrown, but transformed into a NormalTypeError by + // `silent`. This requires different handling in NamesDefaults. + + val c = new Cell(ambiguousName = Some("bla")) + val ambiguousName = c.ambiguousName + } +} diff --git a/test/files/neg/t9041.check b/test/files/neg/t9041.check new file mode 100644 index 0000000000..669e9434e0 --- /dev/null +++ b/test/files/neg/t9041.check @@ -0,0 +1,4 @@ +t9041.scala:11: error: could not find implicit value for parameter cellSetter: CellSetter[scala.math.BigDecimal] + def setCell(cell: Cell, data: math.BigDecimal) { cell.setCellValue(data) } + ^ +one error found diff --git a/test/files/neg/t9041.scala b/test/files/neg/t9041.scala new file mode 100644 index 0000000000..2bdef0d3ae --- /dev/null +++ b/test/files/neg/t9041.scala @@ -0,0 +1,17 @@ +// False negative test, requires overloading in Cell. + +trait Cell { def setCellValue(i: Int) = () ; def setCellValue(d: Double) = () } + +trait Nope { + def f = { + trait CellSetter[A] { + def setCell(cell: Cell, data: A): Unit + } + implicit val bigDecimalCellSetter = new CellSetter[math.BigDecimal]() { + def setCell(cell: Cell, data: math.BigDecimal) { cell.setCellValue(data) } + } + implicit class RichCell(cell: Cell) { + def setCellValue[A](data: A)(implicit cellSetter: CellSetter[A]) = cellSetter.setCell(cell, data) + } + } +} diff --git a/test/files/pos/t9123.flags b/test/files/pos/t9123.flags new file mode 100644 index 0000000000..c16e2f71dc --- /dev/null +++ b/test/files/pos/t9123.flags @@ -0,0 +1 @@ +-optimize -Ydelambdafy:method diff --git a/test/files/pos/t9123.scala b/test/files/pos/t9123.scala new file mode 100644 index 0000000000..22d55b4351 --- /dev/null +++ b/test/files/pos/t9123.scala @@ -0,0 +1,10 @@ +trait Setting { + type T + def value: T +} + +object Test { + def test(x: Some[Setting]) = x match { + case Some(dep) => Some(dep.value) map (_ => true) + } +} diff --git a/test/files/run/t9097.scala b/test/files/run/t9097.scala new file mode 100644 index 0000000000..d2bf55fc44 --- /dev/null +++ b/test/files/run/t9097.scala @@ -0,0 +1,34 @@ +import scala.tools.partest._ +import java.io.{Console => _, _} + +object Test extends StoreReporterDirectTest { + + override def extraSettings: String = List( + "-usejavacp", + "-Xfatal-warnings", + "-Ybackend:GenBCode", + "-Ydelambdafy:method", + "-Xprint:delambdafy", + s"-d ${testOutput.path}" + ) mkString " " + + override def code = """package o + |package a { + | class C { + | def hihi = List(1,2).map(_ * 2) + | } + |} + |package object a { + | def f = 1 + |} + |""".stripMargin.trim + + override def show(): Unit = { + val baos = new java.io.ByteArrayOutputStream() + Console.withOut(baos)(Console.withErr(baos)(compile())) + assert(!storeReporter.hasErrors, message = filteredInfos map (_.msg) mkString "; ") + val out = baos.toString("UTF-8") + // was 2 before the fix, the two PackageDefs for a would both contain the ClassDef for the closure + assert(out.lines.count(_ contains "class hihi$1") == 1, out) + } +} |