8236850: Operations on constant List/Set.of(element) instances does not consistently constant fold

Reviewed-by: smarks, jrose, rriggs, psandoz
This commit is contained in:
Claes Redestad 2020-01-14 23:40:42 +01:00
parent 631b4d2694
commit de96aeddf5
6 changed files with 219 additions and 100 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -450,7 +450,7 @@ public interface Set<E> extends Collection<E> {
*/
@SuppressWarnings("unchecked")
static <E> Set<E> of() {
return (Set<E>) ImmutableCollections.SetN.EMPTY_SET;
return (Set<E>) ImmutableCollections.EMPTY_SET;
}
/**
@ -694,7 +694,7 @@ public interface Set<E> extends Collection<E> {
switch (elements.length) { // implicit null check of elements
case 0:
@SuppressWarnings("unchecked")
var set = (Set<E>) ImmutableCollections.SetN.EMPTY_SET;
var set = (Set<E>) ImmutableCollections.EMPTY_SET;
return set;
case 1:
return new ImmutableCollections.Set12<>(elements[0]);