| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
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..."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 _ =>
}
|
|\
| |
| | |
SI-7285 Fix match analysis with nested objects
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|\ \
| | |
| | | |
SI-7290 Discard duplicates in switchable alternative patterns.
|
| | |
| | |
| | |
| | |
| | |
| | | |
- make a def a val, we only need to compute it once
- add a clarifying comment
- only report the first duplicate
|
| |/
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| | |
Before, we got `error: missing arguments for method f`.
|
|\ \
| |/
|/| |
SI-7251, compiler crash with $.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|\
| |
| | |
SI-7328 Bail out of names/defaults when args are error typed
|
| |
| |
| |
| |
| | |
To avoid a crasher later on with a null type inside a
sequence argument.
|
|\ \
| |/
|/| |
reifier is now aware of SI-7235
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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 2.10.1 into 2.10.x
|
| |\ \
| | |/
| |/|
| | |
| | |
| | |
| | | |
The fix for SI-7183 in 440bf0a8c2 was forward ported in f73d50f46c.
Conflicts:
src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
`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.
|
|/
|
|
|
|
| |
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.
|
|\
| |
| | |
SI-5675 Discard duplicate feature warnings at a position
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|\ \
| | |
| | | |
Booking more progress on SI-6666
|
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
| | |
| | |
| | |
| | | |
Replaces more VerifyErrors with implementation restrictions.
|
| | |
| | |
| | |
| | |
| | | |
This one lands in the new implementation restriction
which beats the VerifyError.
|
|\ \ \
| | | |
| | | | |
SI-7070 Turn restriction on companions in pkg objs into warning
|
| | |/
| |/|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
|\ \ \
| | | |
| | | | |
[nomaster] SI-7064 Reflection: forward compat for 2.10.1
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
This reverts commit 40063b0009d55ed527bf1625d99a168a8faa4124.
Conflicts:
src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
src/compiler/scala/tools/nsc/typechecker/Typers.scala
|
| |/ /
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This reverts commit 0ebf72b9498108e67c2133c6522c436af50a18e8.
Conflicts:
src/compiler/scala/tools/nsc/typechecker/Typers.scala
src/reflect/scala/reflect/internal/Trees.scala
|
|/ /
| |
| |
| |
| |
| |
| | |
In the interests of not breaking source compability.
A few projects are relying on this bug.
Should not be merged to master.
|
|\ \
| | |
| | | |
Analyzer Plugins
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
- 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
|
|\ \ \
| |/ /
|/| | |
SI-6539 moves @compileTimeOnly away from scala-reflect
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
|\ \ \
| | | |
| | | | |
Revert "SI-6601 Publicise derived value contstructor after pickler"
|
| |/ /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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
|
|\ \ \
| | | |
| | | | |
[backport] SI-2968 Fix brace healing for `^case (class|object) {`
|
| |/ /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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)
|
|\ \ \
| | | |
| | | | |
SI-6963 Add version to -Xmigration
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
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.
|
|\ \ \ \
| | | | |
| | | | | |
10 backports
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
[backport]
Prohibit `_` as an identifier, it can only bring badness.
|
| |/ / /
| | | |
| | | |
| | | |
| | | | |
[backport]
The fix of course is a perfect error message.
|
|\ \ \ \
| | | | |
| | | | | |
[backport] SI-5378, unsoundness with type bounds in refinements.
|
| |/ / /
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
As the comment says:
Not enough to look for abstract types; have to recursively check
the bounds of each abstract type for more abstract types. Almost
certainly there are other exploitable type soundness bugs which
can be seen by bounding a type parameter by an abstract type which
itself is bounded by an abstract type.
SPECIAL: BUY ONE UNSOUNDNESS, GET ONE FREE
In refinement types, only the first parameter list of methods
was being analyzed for unsound uses of abstract types. Second
parameter list and beyond had free unsoundness reign. That bug
as well is fixed here.
|
|\ \ \ \
| | | | |
| | | | | |
[backport] the scanner is now less eager about deprecations
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Due to some reason, partest always enables -deprecation. Since Paul has
just submitted a pull request, which removes this behavior, I'm updating
the flags to make sure this test works even after Paul's change.
Backport from https://github.com/scala/scala/pull/1807
Original commit is https://github.com/scala/scala/commit/2015ad3ebd833225e93ed19604760a6da2522bb1
|