summaryrefslogtreecommitdiff
path: root/test/files/neg
Commit message (Collapse)AuthorAgeFilesLines
* SI-6943 warn on value class miscomparison.Paul Phillips2013-04-242-8/+44
| | | | | | | | | | | | | | | | There's a very dangerous situation running around when you combine universal equality with value classes: // All over your code val x = "abc" if (x == "abc") ... // Hey let's make x a value class val x = new ValueClass("abc") // Uh-oh There was until now no warning when comparing a value class with something else. Now there is.
* Merge pull request #2358 from adriaanm/ticket-7330Jason Zaugg2013-04-214-3/+13
|\ | | | | SI-7330 better error when pattern's not a value
| * SI-7330 better error when pattern isn't a valueAdriaan Moors2013-04-084-3/+13
| | | | | | | | | | | | | | | | Somehow an applied type managed to sneak past the type checker in pattern mode. Patterns must be values, though. `case C[_] =>` was probably meant to be `case _: C[_] =>` Advice is dispensed accordingly. (Generalizing the existing advice machinery.)
* | Merge pull request #2408 from paulp/pr/fully-qualified-namePaul Phillips2013-04-194-9/+9
|\ \ | | | | | | Absolute path in error message.
| * | Absolute path in error message.Paul Phillips2013-04-174-9/+9
| | | | | | | | | | | | | | | | | | As soon as you have a directory called "language" lying around, you will appreciate why the advice given regarding SIP-18 should be "import scala.language..." not "import language..."
* | | SI-7388 Be more robust against cycles in error symbol creation.Jason Zaugg2013-04-182-0/+5
|/ / | | | | | | | | | | | | | | | | | | | | | | `Symbol#toString` was triggering `CyclicReferenceError` (specifically, `accurateKindString` which calls `owner.primaryConstructor`.) The `toString` output is used when creating an error symbol to assign to the tree after an error (in this case, a non-existent access qualifier.) This commit catches the error, and falls back to just using the symbol's name.
* / SI-7289 Less strict type application for TypeVar.Adriaan Moors2013-04-084-0/+88
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a type constructor variable is applied to the wrong number of arguments, return a new type variable whose instance is `ErrorType`. Dissection of the reported test case by @retronym: Define the first implicit: scala> trait Schtroumpf[T] defined trait Schtroumpf scala> implicit def schtroumpf[T, U <: Coll[T], Coll[X] <: Traversable[X]] | (implicit minorSchtroumpf: Schtroumpf[T]): Schtroumpf[U] = ??? schtroumpf: [T, U <: Coll[T], Coll[X] <: Traversable[X]](implicit minorSchtroumpf: Schtroumpf[T])Schtroumpf[U] Call it explicitly => kind error during type inference reported. scala> schtroumpf(null): Schtroumpf[Int] <console>:10: error: inferred kinds of the type arguments (Nothing,Int,Int) do not conform to the expected kinds of the type parameters (type T,type U,type Coll). Int's type parameters do not match type Coll's expected parameters: class Int has no type parameters, but type Coll has one schtroumpf(null): Schtroumpf[Int] ^ <console>:10: error: type mismatch; found : Schtroumpf[U] required: Schtroumpf[Int] schtroumpf(null): Schtroumpf[Int] ^ Add another implicit, and let implicit search weigh them up. scala> implicitly[Schtroumpf[Int]] <console>:10: error: diverging implicit expansion for type Schtroumpf[Int] starting with method schtroumpf implicitly[Schtroumpf[Int]] ^ scala> implicit val qoo = new Schtroumpf[Int]{} qoo: Schtroumpf[Int] = $anon$1@c1b9b03 scala> implicitly[Schtroumpf[Int]] <crash> Implicit search compares the two in-scope implicits in `isStrictlyMoreSpecific`, which constructs an existential type: type ET = Schtroumpf[U] forSome { type T; type U <: Coll[T]; type Coll[_] <: Traversable[_] } A subsequent subtype check `ET <:< Schtroumpf[Int]` gets to `withTypeVars`, which replaces the quantified types with type variables, checks conformance of that substitued underlying type against `Schtroumpf[Int]`, and then tries to solve the collected type constraints. The type var trace looks like: [ create] ?T ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]] ) [ create] ?U ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]] ) [ create] ?Coll ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]] ) [ setInst] Nothing ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]], T=Nothing ) [ setInst] scala.collection.immutable.Nil.type( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]], U=scala.collection.immutable.Nil.type ) [ setInst] =?scala.collection.immutable.Nil.type( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]], Coll==?scala.collection.immutable.Nil.type ) [ create] ?T ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]] ) [ setInst] Int ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]], T=Int ) [ create] ?T ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]] ) [ create] ?U ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]] ) [ create] ?Coll ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]] ) [ setInst] Nothing ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]], T=Nothing ) [ setInst] Int ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]], U=Int ) [ setInst] =?Int ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]], Coll==?Int ) The problematic part is when `?Int` (the type var originated from `U`) is registered as a lower bound for `Coll`. That happens in `solveOne`: for (tparam2 <- tparams) tparam2.info.bounds.hi.dealias match { case TypeRef(_, `tparam`, _) => log(s"$tvar addLoBound $tparam2.tpeHK.instantiateTypeParams($tparams, $tvars)") tvar addLoBound tparam2.tpeHK.instantiateTypeParams(tparams, tvars) case _ => }
* Merge pull request #2292 from retronym/ticket/7285Adriaan Moors2013-03-273-0/+69
|\ | | | | SI-7285 Fix match analysis with nested objects
| * SI-7285 Fix match analysis with nested objects.Jason Zaugg2013-03-233-0/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The fix for SI-6146 introduced `nestedMemberType` to enumerate sealed subtypes based on the (prefixed) type of the scrutinee and the symbols of its sealed subclasses. That method needed to widen `ThisType(modSym)`s to `ModuleTypeRef(modSym)` before calling `asSeenFrom`. However, this could lead to confused in the match analysis, which sees `ModuleTypeRef` as distinct from singleton types on the same modules (after all, they aren't =:=). Spurious warnings ensued. This commit makes two changes: - conditionally re-narrow the result of `asSeenFrom` in `nestedMemberType`. - present `a.b.SomeModule.type` as `SomeModule` in warnings emitted by the pattern matcher.
* | Merge pull request #2291 from retronym/ticket/7290Adriaan Moors2013-03-273-0/+21
|\ \ | | | | | | SI-7290 Discard duplicates in switchable alternative patterns.
| * | SI-7290 Minor cleanups driven by review comments.Jason Zaugg2013-03-271-1/+1
| | | | | | | | | | | | | | | | | | - make a def a val, we only need to compute it once - add a clarifying comment - only report the first duplicate
| * | SI-7290 Discard duplicates in switchable alternative patterns.Jason Zaugg2013-03-233-0/+21
| |/ | | | | | | | | | | | | | | | | The pattern matcher must not allow duplicates to hit the backend when generating switches. It already eliminates then if they appear on different cases (with an unreachability warning.) This commit does the same for duplicated literal patterns in an alternative pattern: discard and warn.
* | SI-7299 Improve error message for eta-expanding 23+ param methodJason Zaugg2013-03-252-0/+13
| | | | | | | | Before, we got `error: missing arguments for method f`.
* | Merge pull request #2266 from paulp/issue/7251Paul Phillips2013-03-233-0/+21
|\ \ | |/ |/| SI-7251, compiler crash with $.
| * SI-7251, compiler crash with $.Paul Phillips2013-03-163-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't need to assert our way out of tight spots, we can issue an error. Or so I once thought. It turns out lots of assertions have been disappearing before being heard thanks to "case t: Throwable". Under such conditions, a failed assertion is a no-op, but an error is an error. The crash associated with SI-7251 is best avoided by removing the assertion, which allows an error to be issued in the normal course of events. In the course of trying to figure out the above, I cleaned up ClassfileParser somewhat.
* | SI-7259 Fix detection of Java defined SelectsJason Zaugg2013-03-162-0/+16
|/ | | | | | | | | | | | | | | | | | | | | | | | The fix for SI-3120, 3ff7743, introduced a fallback within `typedSelect` that accounted for the ambiguity of a Java selection syntax. Does `A.B` refer to a member of the type `A` or of the companion object `A`? (The companion object here is a fiction used by scalac to group the static members of a Java class.) The fallback in `typedSelect` was predicated on `context.owner.enclosingTopLevelClass.isJavaDefined`. However, this was incorrectly including Select-s in top-level annotations in Scala files, which are owned by the enclosing package class, which is considered to be Java defined. This led to nonsensical error messages ("type scala not found.") Instead, this commit checks the compilation unit of the context, which is more direct and correct. (As I learned recently, `currentUnit.isJavaDefined` would *not* be correct, as a lazy type might complete a Java signature while compiling some other compilation unit!) A bonus post factum test case is included for SI-3120.
* Merge pull request #2224 from retronym/ticket/7238Adriaan Moors2013-03-112-0/+13
|\ | | | | SI-7328 Bail out of names/defaults when args are error typed
| * SI-7328 Bail out of names/defaults if args are error typedJason Zaugg2013-03-092-0/+13
| | | | | | | | | | To avoid a crasher later on with a null type inside a sequence argument.
* | Merge pull request #2223 from scalamacros/ticket/7235Adriaan Moors2013-03-112-0/+18
|\ \ | |/ |/| reifier is now aware of SI-7235
| * reifier is now aware of SI-7235Eugene Burmako2013-03-092-0/+18
| | | | | | | | | | | | | | | | | | | | SI-7235 is caused by a long-standing todo in typedRefinement, which leads to originals of compound type trees swallowing their stats. I'm not sure how exactly to fix SI-7235, but what I am sure about is that we shouldn't silently discard stats during reification. This patch introduces a new implementation restrictions, which now reports that reify of compound type trees with non-empty stats isn't going to work.
* | Merge pull request #2193 from adriaanm/patmat-refactorAdriaan Moors2013-03-053-63/+0
|\ \ | | | | | | merge 2.10.1 into 2.10.x
| * \ Merge 2.10.1 into 2.10.xAdriaan Moors2013-03-033-63/+0
| |\ \ | | |/ | |/| | | | | | | | | | | | | The fix for SI-7183 in 440bf0a8c2 was forward ported in f73d50f46c. Conflicts: src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala
| | * [nomaster] SI-7195 minor version mustn't introduce warningsAdriaan Moors2013-03-013-63/+0
| | | | | | | | | | | | | | | | | | | | | | | | We want 2.10.1 to be a drop-in replacement for 2.10.0, so we can't start warning where we weren't warning in 2.10.0. See SI-5954 (#1882, #2079) for when it was an implementation restriction, which was then weakened to a warning. It's now hidden behind -Ydebug.
* | | SI-7185 Avoid NPE in TreeInfo.isExprSafeToInlineJason Zaugg2013-03-022-0/+10
|/ / | | | | | | | | | | | | | | | | We got there typechecking code with a redundant layer of Block. We can't express that in source code, so we test this with manual tree construction and with XML literals, which as reported produce such trees.
* | SI-7171 Consider prefix when assessing type finality.Jason Zaugg2013-02-226-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `Type#isFinalType` determines if a type could have a non-bottom subtype. This property is exploited by the pattern matcher to flag impossible patterns. This check was ignoring the type's prefix, and incorrectly deemed that `T#A` in `trait T { final class A }` was a final type. But it could have been subtyped by `U#A` where `U` <:< `T`, or, more simply, by `T.this.A`. Now, type finality requires that the prefix is stable. The existing test cases in neg/patmat-type-check.scala still correctly flag incompatiblities. `isFinalType` is also used by some code that massages pattern matches post specialization. That is actually either broken or obsolete under virtpatmat, I've opened SI-7172 to invesigate that. It is also used by GenICode to determine whether to emit the appropriate equality checks that are correct in the face of boxing. It is possible that this change will force the slow path in some rare cases, but it won't affect correctness.
* | silences t6323aEugene Burmako2013-02-111-0/+6
|/ | | | | | Tag materialization notices enabled with -Xlog-implicits are now echoes not printlns. Therefore, they go into stderr, not stdout, getting logged by partest and not spamming stdout of partest.
* Merge pull request #2095 from hubertp/ticket/5675James Iry2013-02-084-1/+11
|\ | | | | SI-5675 Discard duplicate feature warnings at a position
| * SI-5675 Discard duplicate feature warnings at a positionJason Zaugg2013-02-084-1/+11
| | | | | | | | | | | | | | | | | | | | When -feature has not been enabled, we were double counting identical feature warnings that were emitted at the same position. Normal error reporting only reports the first time a warning appears at a position; feature warning counter incrementing should behave the same way. @hubertp: Fixed .check files that were broken in the original commit.
* | Merge pull request #2017 from retronym/ticket/6666James Iry2013-02-0810-32/+105
|\ \ | | | | | | Booking more progress on SI-6666
| * | SI-6666 Catch VerifyErrors in the making in early defs.Jason Zaugg2013-02-022-4/+15
| | | | | | | | | | | | | | | | | | As we did for self/super calls, add a backstop into explicitouter and lambdalift to check when we try to get an outer pointer to an under-construction instance.
| * | Broader checks for poisonous this references.Jason Zaugg2013-02-0210-49/+90
| | | | | | | | | | | | Replaces more VerifyErrors with implementation restrictions.
| * | Add a test case from the comments of SI-6666.Jason Zaugg2013-02-022-0/+21
| | | | | | | | | | | | | | | This one lands in the new implementation restriction which beats the VerifyError.
* | | Merge pull request #2079 from JamesIry/2.10.x_SI-7070James Iry2013-02-073-6/+7
|\ \ \ | | | | | | | | SI-7070 Turn restriction on companions in pkg objs into warning
| * | | SI-7070 Turn restriction on companions in pkg objs into warningJames Iry2013-02-063-6/+7
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The implementation restriction created from SI-5954 in 3ef487ecb6733bfe3c13d89780ebcfc81f9a5ea0 has two problems. 1) The problematic code works fine if compile with sbt. That means the restriction is breaking some people needlessly. 2) It's not binary compatible. To fix all that this commit changes the error into a warning and removes the setting used to get around the restriction.
* | | Merge pull request #2068 from scalamacros/ticket/7064Adriaan Moors2013-02-0710-13/+28
|\ \ \ | | | | | | | | [nomaster] SI-7064 Reflection: forward compat for 2.10.1
| * | | [nomaster] Revert "refactors handling of parent types"Eugene Burmako2013-02-057-10/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 40063b0009d55ed527bf1625d99a168a8faa4124. Conflicts: src/compiler/scala/tools/nsc/ast/parser/Parsers.scala src/compiler/scala/tools/nsc/typechecker/Typers.scala
| * | | [nomaster] Revert "introduces global.pendingSuperCall"Eugene Burmako2013-02-053-3/+6
| |/ / | | | | | | | | | | | | | | | | | | | | | This reverts commit 0ebf72b9498108e67c2133c6522c436af50a18e8. Conflicts: src/compiler/scala/tools/nsc/typechecker/Typers.scala src/reflect/scala/reflect/internal/Trees.scala
* / / [nomerge] SI-6667 Demote a new ambiguity error to a lint warning.Jason Zaugg2013-02-044-2/+6
|/ / | | | | | | | | | | | | In the interests of not breaking source compability. A few projects are relying on this bug. Should not be merged to master.
* | Merge pull request #2022 from lrytz/analyzerPlugins210Lukas Rytz2013-02-033-3/+32
|\ \ | | | | | | Analyzer Plugins
| * | SI-1803, plus documentation and cleanups in Namers, mainly in typeSigLukas Rytz2013-02-033-3/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - when typing (and naming) a ValDef, tpt and rhs are now type checked in the same context (the inner / ValDef context). this does not change any behavior, but is more uniform (same as for DefDef). martin told me (offline) that this change is desirable if it doesn't break anything. (it doesn't). - typeSig is now more uniform with a separate method for each case (methodSig, valDefSig, etc). methodSig was cleaned up (no more variables) and documented. the type returned by methodSig no longer contains / refers to type skolems, but to the actual type parameters (so we don't need to replace the skolems lateron). - documentation on constructor contexts, type skolems - more tests for SI-5543
* | | Merge pull request #2019 from scalamacros/ticket/6539Eugene Burmako2013-02-012-1/+7
|\ \ \ | |/ / |/| | SI-6539 moves @compileTimeOnly away from scala-reflect
| * | SI-6539 moves @compileTimeOnly away from scala-reflectEugene Burmako2013-01-312-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | The move is done to provide forward compatibility with 2.10.0. The annotation isn't replaced with one of the macro-based solutions right away (see comments for more information about those), because we lack necessary tech in 2.10.x.
* | | Merge pull request #1975 from retronym/ticket/6601-revertJames Iry2013-02-013-8/+0
|\ \ \ | | | | | | | | Revert "SI-6601 Publicise derived value contstructor after pickler"
| * | | Revert "SI-6601 Publicise derived value contstructor after pickler"Jason Zaugg2013-01-263-8/+0
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit b07228aebe7aa620af45a681ef60d945ffc65665. The remedy was far worse than the disease: % cat sandbox/test.scala class V private (val a: Any) extends AnyVal % RUNNER=scalac scala-hash b07228aebe sandbox/test.scala [info] b07228aebe => /Users/jason/usr/scala-v2.10.0-256-gb07228a % scala-hash b07228aebe [info] b07228aebe => /Users/jason/usr/scala-v2.10.0-256-gb07228a Welcome to Scala version 2.10.1-20130116-230935-b07228aebe (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_27). Type in expressions to have them evaluated. Type :help for more information. scala> def foo(v: V) = v.a == v.a exception when typing v.a().==(v.a())/class scala.reflect.internal.Trees$Apply constructor V in class V cannot be accessed in object $iw in file <console> scala.reflect.internal.Types$TypeError: constructor V in class V cannot be accessed in object $iw
* | | Merge pull request #1980 from retronym/backport/1518Adriaan Moors2013-02-014-0/+47
|\ \ \ | | | | | | | | [backport] SI-2968 Fix brace healing for `^case (class|object) {`
| * | | [backport] SI-2968 Fix brace healing for `^case (class|object) {`Jason Zaugg2013-01-264-0/+47
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Squashed commit of the following: commit 24828531f62ce05402c96c04d7096e82d5f4e3bf Author: Jason Zaugg <jzaugg@gmail.com> Date: Sun Oct 21 23:34:35 2012 +0200 SI-2968 Fix brace healing for `^case (class|object) {` The scanner coalesces the pair of tokens into CASEOBJECT or CASECLASS, but fails to set `offset` back to the start of `case`. Brace healing is then unable to correctly guess the location of the missing brace. This commit resets `offset` and `lastOffset`, as though caseobject were a single keyword. Only the former was neccessary to fix this bug; I haven't found a test that shows the need for the latter. (cherry picked from commit cbad218dba47d49a39897b86d467c384538fdd53)
* | | Merge pull request #1998 from JamesIry/2.10.x_6963_2Adriaan Moors2013-02-019-6/+45
|\ \ \ | | | | | | | | SI-6963 Add version to -Xmigration
| * | | SI-6963 Add version to -XmigrationJames Iry2013-01-299-6/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds an optional version parameter to the -Xmigration compiler setting. Doing -Xmigration without version number behaves as it used to by dumping every possible migration warning. This commit adds a ScalaVersion class (plus ancillary stuff), and a ScalaVersionSetting.
* | | | Merge pull request #2015 from paulp/rc1-backportsPaul Phillips2013-01-316-2/+21
|\ \ \ \ | | | | | | | | | | 10 backports
| * | | | SI-6426, importable _.Paul Phillips2013-01-302-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | [backport] Prohibit `_` as an identifier, it can only bring badness.