| Commit message (Collapse) | Author | Age | Files | Lines |
|\
| |
| | |
SI-6514 Avoid spurious dead code warnings
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
`deadCode.expr` stores the method symbol most recently encountered
in `handleMonomorphicCall`, and uses this to avoid warnings
for arguments to label jumps and `Object#synchronized` (which
sneakily acts by-name without advertising the fact in its type.)
But this scheme was insufficient if the argument itself contains
another method call, such as `matchEnd(throw e(""))`.
This commit changes the single slot to a stack, and also
grants exemption to `LabelDef` trees. They were incorrectly
flagged in the enclosed test case after I made the the first change.
|
|/
|
|
|
| |
The prefix in the ImplicitInfo must be com.acme.`package`.type,
rather than com.acme.
|
|\
| |
| | |
Booking more progress on SI-6666
|
| |
| |
| |
| | |
We'll address them in subsequent commits.
|
|\ \
| | |
| | | |
SI-6146 More accurate prefixes for sealed subtypes.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
When analysing exhaustivity/reachability of type tests
and equality tests, the pattern matcher must construct
a set of sealed subtypes based on the prefix of the
static type of and the set of sealed descendent symbols
of that type.
Previously, it was using `memberType` for this purpose.
In simple cases, this is sufficient:
scala> class C { class I1; object O { class I2 } }; object D extends C
defined class C
defined module D
scala> typeOf[D.type] memberType typeOf[C#I1].typeSymbol
res0: u.Type = D.I1
But, as reported in this bug, it fails when there is an
additional level of nesting:
scala> typeOf[D.type] memberType typeOf[c.O.I2 forSome { val c: C }].typeSymbol
res5: u.Type = C.O.I2
This commit introduces `nestedMemberType`, which uses `memberType`
recursively up the prefix chain prefix chain.
scala> nestedMemberType(typeOf[c.O.I2 forSome { val c: C }].typeSymbol, typeOf[D.type], typeOf[C].typeSymbol)
res6: u.Type = D.O.Id
|
|\ \ \
| | | |
| | | | |
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.
|
|\ \ \ \
| | | | |
| | | | | |
SI-5082 Cycle avoidance between case companions
|
| |/ / /
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
We can synthesize the case companion unapply without forcing
the info of the case class, by looking at the parameters in
the `ClassDef` tree, rather than at `sym.caseFieldAccessors`.
Access to non-public case class fields routed through the
already-renamed case accessor methods. The renamings are
conveyed via a back-channel (a per-run map, `renamedCaseAccessors`),
rather than via the types to give us enough slack to avoid
the cycle.
Some special treatment of private[this] parameters is needed
to avoid a misleading error message. Fortunately, we can
determine this without forcing the info of the case class,
by inspecting the parameter accessor trees.
This change may allow us to resurrect the case class ProductN
parentage, which was trialled but abandoned in the lead up
to 2.10.0.
|
| | | | |
|
|\ \ \ \
| |_|/ /
|/| | | |
SI-7060 More conservative dead code elim marking
|
| |/ /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
In dead code elimination, a DROP instruction that gets marked as useful
and can be reached via several paths needs to also mark all the reaching
definitions as useful, else we'll get unbalanced stacks on the two paths.
A simplistic example:
```
BB1:
CALL X // useful, leaves a LONG on the stack
JUMP BB3
BB2:
LOAD_FIELD Y // not useful
JUMP BB3
BB3:
DROP LONG // useful because "CALL X" is useful
// but unless we mark "LOAD_FIELD Y" as useful too
// we'll get unbalanced stacks when reaching BB3
```
This patch addresses the unbalanced stack problem by adding all the
reaching definitions of a useful DROP as useful instructions too.
|
|\ \ \
| |/ /
|/| | |
SI-7033 Be symful when creating factory methods.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Implicit class factory methods were synthesizing the
reference to the class as `Ident(classDef.name)`, which
was unhygienic in case of `implicit class X[X]`.
To use symbols without causing a cycle, I switched from
`REF(symbol)` to `Ident(symbol)`. The former calls into:
at scala.reflect.internal.TreeGen.mkAttributedSelect(TreeGen.scala:184)
at scala.reflect.internal.TreeGen.mkAttributedRef(TreeGen.scala:124)
at scala.reflect.internal.TreeGen.mkAttributedRef(TreeGen.scala:130)
at scala.tools.nsc.ast.TreeDSL$CODE$.REF(TreeDSL.scala:307)
which forces the info of enclosing module and forms a cycle.
|
|\ \ \
| | | |
| | | | |
Analyzer Plugins
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Before:
scala> class A { class C extends { val x: A = this } with AnyRef }
<console>:7: error: type mismatch;
found : A.this.C
required: A
class A { class C extends { val x: A = this } with AnyRef }
^
Note that the same thing is necessary and already done in Namers (see
def createNamer). The whole logic of when and how to create contexts
should be factored out and reused in Namer and Typer.
(
My Hobby [1]: detecting compiler by just looking at its soruce
[1] http://www.explainxkcd.com/wiki/index.php?title=Category:My_Hobby
)
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
- 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
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Integrates annotationsLub into lub.
Also fixes SubstSymMap when mapping over annotaion trees. I don't
understand what the previous code was supposed to achieve, but it
crashed in some of my examples.
|
| | | |
| | | |
| | | |
| | | |
| | | | |
As reported against 2.10.0, and as fixed by SI-6482,
which was backported in the previous commit.
|
|/ / /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Squashed commit of the following:
commit 5c156185306ba797c0443d9dccae0ae7ce462a1f
Author: Paul Phillips <paulp@improving.org>
Date: Sat Oct 6 15:42:50 2012 -0700
A little more housecleaning in ExtensionMethods.
The only real contribution is readability.
(cherry picked from commit 61f12faacaaccf366f9211ba6493fb042a91f1d2)
Conflicts:
src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala
commit 79f443edf584745d614e24fb9ca6644c6b18d439
Author: Paul Phillips <paulp@improving.org>
Date: Sat Oct 6 14:22:19 2012 -0700
Incorporated pull request feedback.
(cherry picked from commit 153ccb4757718cceb219988f30381f73362e6075)
commit 707f580b0cdcb01e27ca4c76991dea427945b5bd
Author: Paul Phillips <paulp@improving.org>
Date: Sat Oct 6 10:20:45 2012 -0700
Fix for SI-6482, lost bounds in extension methods.
That was a good one. How to create a new method with type
parameters from multiple sources, herein.
(cherry picked from commit ff9f60f420c090b6716c927ab0359b082f2299de)
commit 8889c7a13f74bc175e48aa2209549089a974c2af
Author: Paul Phillips <paulp@improving.org>
Date: Fri Oct 5 22:19:52 2012 -0700
Responded to comment about how many isCoercibles there are.
I make the case that there is only one.
(cherry picked from commit 883f1ac88dd7cec5882d42d6b48d7f267d1f6e00)
|
|\ \ \
| | | |
| | | | |
Revert "SI-6601 Publicise derived value contstructor after pickler"
|
| |/ /
| | |
| | |
| | |
| | | |
This demonstrates the need for the reversion in the
previous commit.
|
|\ \ \
| | | |
| | | | |
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]
Saw this by accident; the trees created for early defs would
wholesale replace the modifiers with PRESUPER rather than
combining them. FINAL was lost that way, as would be any other
modifiers which might be valid there.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
[backport]
You don't want to do name-based selections in later phases
if you can help it, because there is nobody left to resolve
your overloads. If as in this example you're calling a
known method, use the symbol. Review by @hubertp.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
[backport]
mkAttributedSelect, which creates a Select tree based on
a symbol, has been a major source of package object bugs,
because it has not been accurately identifying selections
on package objects. When selecting foo.bar, if foo turns
out to be a package object, the created Select tree must be
foo.`package`.bar
However mkAttributedSelect was only examining the owner of
the symbol, which means it would work if the package object
defined bar directly, but not if it inherited it.
|
| | | |
| | | |
| | | |
| | | |
| | | | |
[backport]
And other polishing related to varargs handling.
|
| | | |
| | | |
| | | |
| | | |
| | | | |
[backport]
Remove some code, win a prize.
|
|\ \ \ \
| | | | |
| | | | | |
SI-6968 Simple Tuple patterns aren't irrefutable
|
| | |/ /
| |/| |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Reverts part of c82ecab. The parser can't assume that
a pattern `(a, b)` will match, as results of
`.isInstanceOf[Tuple2]` can't be statically known until
after the typer.
The reopens SI-1336, SI-5589 and SI-4574, in exchange for fixing
this regression SI-6968. Keeping all of those fixed will require
a better definition of irrefutability, and some acrobatics to
ensure safe passage to the ambiguous trees through typechecking.
|
|\ \ \ \
| | | | |
| | | | | |
SI-7035 Centralize case field accessor sorting.
|
| |/ / /
| | | |
| | | |
| | | |
| | | |
| | | | |
It is both burdensome and dangerous to expect callers
to reorder these. This was seen in the field permutation
in the unapply method; a regression in 2.10.0.
|
| |/ /
|/| |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
I gift-wrapped this ticket four months ago:
'I think it will be enough to say "tpe =:= MacroContextClass.tpe"
rather than == .'
Indeed. Had to open my own gift. Thanks, paulp!
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
trait T { type U }
class A(val a: T) extends AnyVal {
def foo[TT <: a.U] = 0
}
It works! But it's pure serendipity. After extmethods,
the careful student of ASTs will find:
object A {
final def foo$extension[TT >: Nothing <: A.this.a.U]($this: A): Int = 0;
}
`A.this` doesn't belong.
For now we just include this case under our test umbrella.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This allows for the likes of:
class A[X](val x: X) extends AnyVal {
def foo(xy: x.Y) {}
}
We have to do this in both directions, when synthesizing
the extension method in `Extender#transform`, and later on
when Erasure tries to find the corresponding extension
methods by backing out the original signatures from
the signatures of the synthesized methods in the companion.
In the first case, we have to be careful to use a stable
reference to the `self` parameter, which can satisfy the
dependent types.
|
|\ \ \
| | | |
| | | | |
[backport] SI-3577 BoundedWildcardType handling
|
| |/ /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
commit 3c91b32d699a9e29d685ac20c9805f96c9f2db2c
Author: Jason Zaugg <jzaugg@gmail.com>
Date: Fri Aug 24 01:16:47 2012 +0200
Mention BoundedWildcardType in "a standard type pattern match".
(cherry picked from commit 00e46b3dbcea2b72fd3941b7ffc2efba382871e9)
commit 0664be2b69b1ce013e937bc93f4e84b891676f1f
Author: Jason Zaugg <jzaugg@gmail.com>
Date: Fri Aug 24 01:05:07 2012 +0200
Make RefChecks#validateVariance aware of BoundedWildcardType.
The only test case that I know for this will be neutered
by the imminent fix for SI-6258; so I haven't been able to
test this.
But trying this manually, you can see that this patch defers the
the SI-6258 to the erasure phase.
Original:
scala.MatchError: ? (of class scala.reflect.internal.Types$BoundedWildcardType)
at scala.tools.nsc.typechecker.RefChecks$RefCheckTransformer$$anon$3.scala$tools$nsc$typechecker$RefChecks$RefCheckTransformer$$anon$$validateVariance$1(RefChecks.scala:894)
at scala.tools.nsc.typechecker.RefChecks$RefCheckTransformer$$anon$3.validateVariance(RefChecks.scala:965)
Modified:
java.lang.ClassCastException: scala.reflect.internal.Types$TypeRef$$anon$6 cannot be cast to scala.reflect.internal.Types$TypeBounds
at scala.reflect.internal.Types$TypeMap.mapOver(Types.scala:4160)
at scala.reflect.internal.transform.Erasure$ErasureMap.apply(Erasure.scala:156)
(cherry picked from commit 2b4e7183fd24113cca5e868456668fd05c848168)
commit 6ad651c94faf463133c742feb2aee59ef782ea1f
Author: Jason Zaugg <jzaugg@gmail.com>
Date: Fri Aug 24 00:54:59 2012 +0200
SI-3577 Make varianceInType aware of BoundedWildcardType.
(cherry picked from commit 21105654c40ed0c462142bcbb6c8eced77f8b07a)
|
|\ \ \
| |/ /
|/| | |
SI-6891 Fix value class + tailrec crasher.
|
| |/
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
rhs.substituteSymbols(old, new) leaves us with:
def loop#12225(x#12226: A#15491): scala#21.this.Unit#1615 =
loop#12225(x#12226)
In which the TermSymbol x#12226 has a stale info, pointing at
the A#7274, the class type parameter, rather than A#15491,
the corresponding type parameter of the synthetic backing
method.
I've improved `TreeSymSubstituter` to substitute not
only `Tree#{tpe, symbol}`, but also `DefTree#sym.info`.
The `pos` test that triggered the new code path are
listed here: https://gist.github.com/4575687
AFAICS, no special treatment of Function, Return, or Import
is needed in TreeSymSubstutor.
|
|\ \
| | |
| | | |
SI-7011 Fix finding constructor type in captured var definitions
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
If a captured var was initialized with an empty tree then finding
the type of the empty tree was being handled improperly. The fix is
to look for primary constructors on the tree's type symbol rather than
the tree's symbol.
A test is included. In order to make the problem more testable the debug
logging of the issue is changed to a debug warn.
|
|\ \ \
| | | |
| | | | |
SI-6976 Fix value class separate compilation crasher.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
We can't guarantee that the owner of the value class
is initialized, and if it isn't, the search for the
companion module will turn up bubkis.
This is a localized fix, but I'd be suprised if there
weren't other places that suffered from the same problem.
Wouldn't it be nicer to have something like:
// doesn't force info
sym.raw.info
sym.raw.companionModule
// forces info
sym.info
sym.companionModule
|
|\ \ \ \
| |_|/ /
|/| | | |
SI-6994 Avoid spurious promiscuous catch warning
|
| | |/
| |/|
| | |
| | |
| | | |
It was being issued upon re-typechecking of a transformed
tree. Now we disable the warning post-typer.
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Avoid blowing the stack/the analysis budget by more eagerly translating
the propositions that model matches to CNF.
First building a large proposition that represents the match,
and then converting to CNF tends to blow the stack.
Luckily, it's easy to convert to CNF as we go.
The optimization relies on `CNF(P1 /\ ... /\ PN) == CNF(P1) ++ CNF(...) ++ CNF(PN)`:
Normalizing a conjunction of propositions
yields the same formula as
concatenating the normalized conjuncts.
CNF conversion is expensive for large propositions,
so we push it down into the conjunction and
then concatenate the resulting arrays of clauses (which is cheap).
(CNF converts a free-form proposition into an `Array[Set[Lit]]`, where:
- the Array's elements are /\'ed together;
- and the Set's elements are \/'ed;
- a Lit is a possibly negated variable.)
NOTE:
- removeVarEq may throw an AnalysisBudget.Exception
- also reworked the interface used to build formula,
so that we can more easily plug in SAT4J when the time comes
|