A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/commit/7849db4c0c0c1600e3c848f6474fdd508c3af095 below:

Fix corner case with glb associativity · pmd/pmd@7849db4 · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+26

-5

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+26

-5

lines changed Original file line number Diff line number Diff line change

@@ -409,12 +409,24 @@ static JTypeMirror glb(TypeSystem ts, Collection<? extends JTypeMirror> types) {

409 409

}

410 410 411 411

private static boolean containsDuplicateParameterizations(List<JTypeMirror> bounds) {

412 +

// note: this could be more efficient if we used a tree depth

413 +

// measure to order types, like what the JVM does internally.

414 +

// Eg if depth(T) < depth(S), then T <: S is definitely false.

415 + 412 416

for (int i = 0; i < bounds.size(); i++) {

413 417

JTypeMirror bi = bounds.get(i);

414 -

for (int j = i + 1; j < bounds.size(); j++) {

418 +

for (int j = 0; j < bounds.size(); j++) {

419 +

if (i == j) {

420 +

continue;

421 +

}

415 422

JTypeMirror bj = bounds.get(j);

416 -

if (bi.getErasure().equals(bj.getErasure())) {

417 -

return true;

423 +

if (bj instanceof JClassType) {

424 +

if (bi.getAsSuper(((JClassType) bj).getSymbol()) != null) {

425 +

// since we know bi and bj are unrelated,

426 +

// this must mean that bi has an unrelated

427 +

// parameterization of |bj| in its supertypes

428 +

return true;

429 +

}

418 430

}

419 431

}

420 432

}

Original file line number Diff line number Diff line change

@@ -674,7 +674,8 @@ public JTypeMirror lub(Collection<? extends JTypeMirror> types) {

674 674

*

675 675

* <p>If after these transformations, only a single component remains,

676 676

* then that is the returned type. Otherwise a {@link JIntersectionType}

677 -

* is created.

677 +

* is created, unless the components are incompatible, in which case

678 +

* {@link #NULL_TYPE} is returned.

678 679

*

679 680

* <p>See also JLS§4.9 (Intersection types).

680 681

*

Original file line number Diff line number Diff line change

@@ -46,7 +46,7 @@ class GlbTest : FunSpec({

46 46 47 47

test("Test intersection left associativity") {

48 48 49 -

checkAll(PropTestConfig(-1697903442944791680), ts.allTypesGen, ts.allTypesGen, ts.allTypesGen) { t, s, r ->

49 +

checkAll(ts.allTypesGen, ts.allTypesGen, ts.allTypesGen) { t, s, r ->

50 50

if (canIntersect(t, s, r)) {

51 51

glb(glb(t, s), r) shouldBe glb(t, s, r)

52 52

}

@@ -69,6 +69,14 @@ class GlbTest : FunSpec({

69 69

glb(t_List, `t_List{?}`) shouldBe `t_List{?}`

70 70 71 71

}

72 + 73 +

test("Test GLB corner cases") {

74 + 75 +

glb(t_Iterable[`?` extends t_Number], t_Iterable[t_String]) shouldBe ts.NULL_TYPE

76 +

glb(`t_ArrayList{Integer}`, ts.NULL_TYPE) shouldBe ts.NULL_TYPE

77 +

glb(`t_ArrayList{Integer}`, t_Iterable[`?` extends t_Number], t_Iterable[t_String]) shouldBe ts.NULL_TYPE

78 + 79 +

}

72 80

}

73 81

}

74 82

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4