500 Commits

Author SHA1 Message Date
Andreas Dangel
cda155891a [java] Add ugly lookahead for local record declarations
so that it can be distinguished from local var decl or other
statements.
2020-08-14 20:56:26 +02:00
Andreas Dangel
4d2853ccc4 [java] Add support for local records (Java 15 Preview) 2020-08-14 18:55:00 +02:00
Clément Fournier
2963dac4fc Add void type node to replace ResultType 2020-08-14 07:37:19 +02:00
Andreas Dangel
e51519c5fd [java] Support Records with Java 15 Preview 2020-08-13 20:42:08 +02:00
Andreas Dangel
e596a67297 [java] Support Pattern Matching for instanceof with Java 15 Preview. 2020-08-13 20:11:25 +02:00
Andreas Dangel
40f0eedf88 [java] Text Blocks are now a permanent language feature with JDK 15 2020-08-13 20:05:54 +02:00
Andreas Dangel
02a78f5bea [java] Add versions 15 (new default) and 15-preview, remove 13-preview 2020-08-13 19:15:02 +02:00
Clément Fournier
067102a9c5 Cleanup primitive type 2020-07-26 17:50:10 +02:00
Clément Fournier
2ace5798f4 Merge branch 'grammar-annot-disambig' into typeres-jtypes 2020-07-26 16:36:47 +02:00
Clément Fournier
2449f6404e New typeres framework
Ceci est la combinaison de 338+ commits.

    Make set of classes to mirror types

    Implement capture conversion

    Document

    Doc

    Implement contains for targs

    Implement toString

    Fully implement subtyping

    Check for reifiability

    Implement unchecked, fix array subtyping

    Test rec typevar building

    Test primitive subtyping

    Test array subtyping

    Test wildcards subtyping

    Doc

    Rename primitiveType

    Reify conversions

    Test boxing

    Make constants for common types

    Test type param mutual recursion

    More defensive validation

    Implement numeric promotion

    Checkstyle

    Implement supertype set

    Implement lub

    Fix infinite recursion

    Fix lub bugs

    Use linkedhashset for stable ordering

    Add primitives to common types

    Move common types into type factory

    Try a lazy class resolver, needs a symbol table

    Improve lazy resolver

    Implement conditional expr typing

    remove poly impl

    Represent primitive wrappers differently

    Better compromise for primitive wrappers

    Extract wildcard interface

    Extract array type interface

    Refactor to extract interfaces

    Don't depend on initialization of jprimitiveType

    Finish pretty printer

    Remove dependency on reflection

    Fix class initialization trouble

    Move to type constants

    Use regular impl for OBJECT

    Encapsulate ops into TypeOps

    Add inference var to model

    Impl some ops

    Add some type inference algos

    Invocation context compatibility

    Add incorporation

    Generify bound set with ExprOps

    Add applicability tests

    Fix compil

    Add incorporation actions

    Implement incorporation

    Add inference steps

    Implement brute force walk strategy

    Remove some type params

    Wire in everything

    Implement methodtype

    Access methods from JClassType

    Represent enclosing types

    Work on overriding

    Implement expr ops

    Catch easy cases

    Diamond inference

    Fix pretty printer

    Fix concurrent mod

    Test

    Add reflect info to JModifier

    Add symbolic type declaration

    Most specific check

    Test with nested invocation

    Test lub

    Add constraints for lambdas and all subexpressions

    Resolve full call chain with lambdas

    Set partial results on nodes

    Test chain

    Doc

    Generalise expr mirrors

    Fix context

    Add invocation mirror

    Add support for method references

    make infer static

    Cleanup interface

    Fix constructor access

    Test method reference

    Cleanup method ref types

    Test constructor reference

    Test overload resolution, fix TODO

    Fix ctdecl of mref on non-ground target type

    Add graph walk strategy

    Document

    Use toposort

    Make enum constant implement ctor invoc mirror

    Work on context

    Test conditional expr type

    Handle switch exprs uniformly

    Fix bugs

    Add type inference performance test case

    Add overload resolution tests

    Cache result of overload selection, only recompute invocation

    Optimise common case in graph building

    Optimise propagation by merging variables

    Fix some tests, cleanup

    Preserve applicability phase

    Improve jsinglechildnode

    Add way to get a field's type

    Make more complex stress test

    Cache bound check results

    Type projection for inference

    Simplify lazy type inference of var ids

    Improve memory usage

    - reuse constant enum sets (by far the biggest leak, given the number of PropagateBounds created)
    - implement substitution without a visitor

    Optimise imports

    Cache hash of classes

    Cleanup

    Add overloads test

    Fix context fetching

    Fix lub bug

    Test switch expr

    Fix rebase

    Remove useless type

    Factorise poly check

    Remove base poly expr

    Fix array initializer

    Remove duplicated numeric literal typing

    Fix inferred iterable type

    Move method resolution phase to upper level

    Delete useless var

    Commit pr plan

    Remove useless method

    Fix enclosing type comb rule

    REVERT ME Remove partial enclosing type support

    Add package info

    Put task list in branch description

    Fix old rebases

    Fix rebase

    Simplify for left recursive ops

    Fix comments

    Fix rebase

    Revert "REVERT ME Remove partial enclosing type support"

    This reverts commit 8080ff1585b3a760fafc957282771baf716f3c7f.

    WIP base type mirrors on symbols

    Make JMethodType not a JTypeMirror

    Figure out getSymbol & type vars

    make type factory non-static

    Add a parameter to visitors

    Fix compilation

    Use symbol table in lazy type resolver

    Move package

    Fix most tests

    Move internal api around

    Specify some stuff

    Split reflect impl from API

    Make AST impl

    Equality routines

    Fix tests

    Move internal symtable doc

    Improve symtableResolver ergonomics

    Poly res tests

    Make AST type factory

    Update

    Make lambda expressions not a MethodlikeNode

    Build local var sym

    Update for switches

    Make Infer not static, fix logging

    Don't expose visitor nature of SymbolResolver

    Cleanup

    Improve type error handling

    Don't throw away CTdecls for an arg mismatch

    Fix more tests

    Local symbol tables

    Symbol table looks in interfaces

    Incompatible changes that should stay on this branch and not be squashed

    ResolveResult

    Explicitly typed lambdas

    Fix some static bugs

    Fix a lot of bugs

    Use FQCN symtable

    Move parsing contexts to upper level

    Cleanup

    DSL to test types

    test subst

    Dont create an exception for each failure

    Stack trace creation takes a significant amount of time

    Remove laziness for fetching method streams

    Streams obfuscate performance analysis by
    delaying the computation until the last
    moment.

    Fix some bugs with unresolved classes

    Also measure performance: full typeres
    is around same time as parsing. This is
    great. At this point 80% of all types
    are resolved (though some type inference
    results are probably incorrect). Mostly
    this comes from the fact that there are
    still AmbiguousNames in the tree.

    Fix problem with varargs

    Handle enclosing types

    Enclosing types

    Fix compil

    Add another stress test

    Refactor primitive subtyping

    Fix rebase

    Fix rebase: tests

    Figure out type factories WIP

    Move type ops into TypeOps

    Move AsSuper

    Figure out type factories WIP

    Make TypeSystem object

    wip

    WIP

    WIP

    Make typeops static

Fix grounding routine

Fix bug with return type

Start fixing tests

Cleanup primitive types

Fix some tests

Add todo

Remove JDK test dependency

Test cases lubbing String and
StringBuilder produce different
outputs on JDK [8, 11[ and 11+, because
StringBuilder was made a Comparable<StringBuilder>
in JDK 11

Implement most specific method selection

Drop JVariableSig from symbol table

Use asOuterSuper instead

Fix local var type inference with foreach.

Fix a lot of stuff based on jdk 12 run

Make type system own symbol factories

Fix intersection with bound

Fix standalone ternary types

Capture field access type

Eg class Foo<T> { T[] field; }
Foo<? extends T>.field : capture(T)[]

Add tests

Delete lexical substs

Fix reflected owner type

Add graph viz

Fix bug with graph reduction

Optimise ivar dependency reduction
by a lot. The previous 60s stress
test now takes 600ms.

Btw at this point type res for the
whole JDK 12 codebase takes 25 secs,
down from 175 on 6.20.0 (7x speedup).

Implement inherited field/class lookup

Fix scoping inside switch statements

Fix a few bugs

Handle inherited methods

Interfaces should inherit Object methods

Move lub into TypeSystem

Handle class types induced by intersections

Fix lambda congruence

Test lambda with intersection type

Fix inference

Fix same type check using equals

Simplify intersection type induction

Remove type sys extension

Simplify sym factories

Finish symbol factory streamlining

Document

Cache non-erased symbols separately

Doc

Revert, erased types are only raw

Get rid of generic constants in TypeSystem

Remove some dead code

Fix exact method reference

Improve unchecked conversion handling

Fix dependency of delegated ivars

Improve logging, fix a few bugs

Test enclosing types

Improve loggin

Print file location

Fix subtyping for wildcards

Fix standalone method types

Fix boxing conversion

Fix promotion on unary exprs

Implement special treatment of getClass()

Add tests for anon classes

Make symbol tables use lists for methods

Fix method reference with void target type

Move graphUtils

Make unresolved types bottom

(instead of top)

It's more likely to be useful. Eg.

Unresolved var = ...;

knownMethod(var);

Here, var must conform to the parameter,
if it is unresolved, we assume that's the
case. Otherwise we would fail resolution
of knownMethod for this call site.

The reverse situation is rarer.

Fix conversions in loose phase

Make JInferenceVar a class

Hide TypePair

Remove special string type

Fix toString of anon classes

Implement overload specificity for generic methdos

Fix anon class ctors

Fix Object methods not in scope in interfaces

Fixing anon class ctors WIP

Fix rebase

Cleanup

Print type var bounds

Fix tests, improve pretty printing

Hide ast sym factory

Fix array method erasure

Fix superclass, uncover bug with substitution

Substitute  type param bounds

Make Array have Object methods

Fix duplicated logging categories

Make root symbolFactory thread safe

Fix overload ambiguity with hiding

Fix exact method when they shadow each other

Make PMultimap type

Make shadowGroup

Make a few utilities to replace import tables

Replace other tables

Cleanup

Compat with old impl

Fix rebase

Port to using sigs

Make base class for shadow groups

Fix method group

Test shadowing of inherited members

Fix bugs with tparams

Specialize to StringMultimap

Big optimizations

Simplify a lot of things, remove caching
of getAllMethods

Factorize group implementations

Add resolveFirst

Fix bug with ctor invocation

Fix type parsing for union types

Generify multimap

Implement nextShadowGroup

Remove unused API of pmultimap

Use interface where possible

Fix tests

Use singleton resolvers more frequently

Remove commons collections dependency

Tries don't make a significant difference
in execution time. Mostly because tries
used in symbol tables are very small.

Remove some api of jtypemirror

Fix shadow barriers

Fix accessibility check for protected member

Qualified ctor invocations have access to inner class name

Make strict stream for profiling

LOOK AT ME strict streams

Strict streams are actually *much* more
efficient for our use case

Extract some stuff into CollectionUtil

Make methods shadow each other

doc

Simplify OptionalBool

Improve strict stream

Eventually I'll remove it

Doc newer symtable

Make PMultimap type

Make shadowGroup

Make a few utilities to replace import tables

Cleanup

Checkout newer sym table from typeres branch

Port

Checkout tests

Port tests, remove old impl

Extract augment function

Move classes back into internal package

Abstract stuff away for pmd-core

Optimise singular map case even more

Fix nextShadowGroup WIP

Make ShadowIterator to replace getNextGroup

Use chain iterator

Add tests

Finish impl

Add tests for supertype enumerator

Add tests for method shadowing in imports

Port to using types etc

Fix tests

Fix outdated tests

Fix anon class ctors

Fix more outdated tests

Object methods should be in scope in interfaces

Fix compil

Make simple signature parser

Make stubs

Figure out loading logic

Progress on type param parsing

Do away with nested classes

Class signatures

It works!

Parse tvar bounds lazily

Fix a lot of stuff

No errors on pmd-core

JDK 13 under 80s

Implement toString everywhere

Try to make the whole thing thread safe

Still a spurious NPE, access flags are weird.
For j.l.invoke.DelegatingMethodHandle
(declared as `final class Holder {}`) the
access flags from the class file are 0x32, and
the enclosing type is null, while when accessed
through reflection, the access flags are correctly
0x10. The class is engineered through VM magic
so idk what happens

Remove shared caching of TypeSystem

The sub caches are not useful anymore
and creating them all the time is wasteful

Add some tests

Fix improper locking

Reorganise typeSystem initialization

Change the name

Doc

Opts

Optimise away some expensive lookaheads in the parser

Doc

Fix modifiers

Optimise big switches in parser

Placing token decls that are frequently used together closer
increases the chance that the compiler generate a TABLESWITCH
instruction instead of a LOOKUPSWITCH. Table switches take
constant lookup time, while lookupswitch is linear. Selection
of table switch is now done for the biggest switches of the
parser: the one in types, in modifiers, in statements, and
at the start of expressions. Other lookup switches are unimportant
because they have very few labels (typically 2).

Optimise variable initializer lookahead

make test rule noop

PARSER Optimise common branches in expressions

PARSER opt blocks & statements

doc

Don't accept void by default

Split signature parsers

Simplify type param parsing

Simplify type params parsing

Some optimisations

Tests

Simplify synchronization

Factorize synchronization logic

Move ConsList into pmd-core

Prune more empty nodes

Use single map for asm resolver

Remove changes to parser

Add option to suppress type inference log entry creation

Use soft references to allow class stubs to be GCed

Fix rebase
2020-07-26 16:35:10 +02:00
Clément Fournier
64ee073fca Annotation disambiguation 2020-07-25 00:30:30 +02:00
Clément Fournier
ce790f8193 Fix merge 2020-05-02 21:02:55 +02:00
Clément Fournier
82c35aa3e8 Unimportant grammar cleanups 2020-04-08 21:23:49 +02:00
Andreas Dangel
735cbad432 Merge branch 'pmd/7.0.x' into java-grammar 2020-04-04 19:15:53 +02:00
Andreas Dangel
ef1c50707b [java] Fix compile errors 2020-04-04 19:03:22 +02:00
Andreas Dangel
c8ffb63e40 Merge remote-tracking branch 'origin/master' into pmd/7.0.x 2020-04-04 18:36:27 +02:00
Andreas Dangel
69ed0464a7 Merge branch 'pr-2385'
[java] Make yield statements more conditional #2385

Fixes #2319
2020-04-04 18:20:49 +02:00
Clément Fournier
9a2810a4e3 Merge branch '7.0.x' into java-grammar 2020-03-28 15:28:34 +01:00
Clément Fournier
571a4167b8 Merge branch 'master' into 7.0.x 2020-03-28 15:14:09 +01:00
Clément Fournier
e1a4b8ae97 Forbid type params for record ctors 2020-03-28 11:43:20 +01:00
Clément Fournier
b01d4dc0d7 Test 2020-03-28 11:36:42 +01:00
Clément Fournier
9e9c370a4a Make yield more conditional
Refs #2319
2020-03-28 11:36:38 +01:00
Clément Fournier
080c0c15cb Merge branch 'grammar-flatten-body-declarations' into java-grammar 2020-03-17 15:22:02 +01:00
Clément Fournier
fa58ac98d2 Add empty modifier list for pattern variables 2020-03-03 00:01:23 +01:00
Clément Fournier
9b720c81b1 Merge branch 'java-grammar' into grammar-flatten-body-declarations 2020-03-02 22:35:47 +01:00
Clément Fournier
ea0122a656 Merge branch 'master' into 7.0.x 2020-03-02 22:26:41 +01:00
Clément Fournier
f698a2e7aa Small API improvements for records 2020-03-02 22:24:44 +01:00
Clément Fournier
2910303dd8 Merge branch '7.0.x' into java-grammar 2020-03-02 22:06:32 +01:00
Clément Fournier
f574b7929b Merge branch 'master' into 7.0.x 2020-03-02 20:46:59 +01:00
Clément Fournier
18cc6a3e4e Disallow throws clause on record constructor 2020-03-02 20:46:40 +01:00
Clément Fournier
c8c8a04dda Fix new java nodes 2020-03-02 20:31:52 +01:00
Clément Fournier
9788a3af5d Merge branch 'master' into 7.0.x 2020-03-02 19:12:28 +01:00
Clément Fournier
fc0b437ad7 Fix record ctor with throws 2020-03-02 19:00:59 +01:00
Andreas Dangel
f1fe8ce5e1 [java] Remove version java 12 preview
Keep the tests and move them to java 14
except for the break expression
2020-02-28 19:37:13 +01:00
Andreas Dangel
ee211d42b1 [java] Remove unneccessary annotation parsing 2020-02-28 19:07:03 +01:00
Andreas Dangel
7d3df99134 [java] RecordBody - test with more annotation and use deep lookahead
Record constructors are not allowed to throw exceptions.
2020-02-28 18:41:22 +01:00
Andreas Dangel
0ecd1da200 [java] Get rid of RecordBodyDeclaration node 2020-02-28 18:32:33 +01:00
Andreas Dangel
fa28aa7e23 [java] Test annotations with RecordComponents 2020-02-28 17:59:39 +01:00
Andreas Dangel
e017def280 [java] Support vararg/array in RecordComponent and empty components 2020-02-28 17:35:44 +01:00
Andreas Dangel
5f43e198d5 [java] RecordConstructorDeclaration - do not use Name() 2020-02-28 17:01:57 +01:00
Andreas Dangel
9917e3f422 [java] RecordComponents -> RecordComponentList 2020-02-28 16:56:43 +01:00
Andreas Dangel
e2d84d6741 [java] Add grammar jdoc for new Record types 2020-02-28 16:50:57 +01:00
Andreas Dangel
8a224462fd [java] Add initial support for Java 14 Preview record types 2020-02-28 14:58:52 +01:00
Andreas Dangel
adfb2ab129 [java] Update grammar 2020-02-28 10:51:38 +01:00
Andreas Dangel
9a80f13164 [java] Fix new escape sequence "\s" detection 2020-02-27 21:23:33 +01:00
Andreas Dangel
d16751d136 [java] Add support for TextBlocks in Java14
* New escape sequence "\s" added
* Added experimental ASTLiteral::getTextBlockContent to retrieve
  the text block with stripped indentation
2020-02-27 21:11:02 +01:00
Andreas Dangel
9d5b7554f0 [java] Make sure, SwitchExpressions with yield work with java14
Add additional tests for java14, so that we can later simply remove
the java13 preview tests
2020-02-27 18:30:39 +01:00
Clément Fournier
326784f5db Merge branch 'java-grammar' into grammar-flatten-body-declarations 2020-02-21 14:56:22 +01:00
Andreas Dangel
a67043edc5 Merge branch 'pr-2282' into java-grammar
[java] Use single node for annotations
2020-02-20 11:08:16 +01:00
Clément Fournier
05e1ba0c10 Remove TypeDeclaration 2020-02-19 18:38:24 +01:00