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
@ -789,7 +789,7 @@ public interface List<E> extends Collection<E> {
*/
@SuppressWarnings("unchecked")
static <E> List<E> of() {
return (List<E>) ImmutableCollections.ListN.EMPTY_LIST;
return (List<E>) ImmutableCollections.EMPTY_LIST;
}
/**
@ -1033,7 +1033,7 @@ public interface List<E> extends Collection<E> {
switch (elements.length) { // implicit null check of elements
case 0:
@SuppressWarnings("unchecked")
var list = (List<E>) ImmutableCollections.ListN.EMPTY_LIST;
var list = (List<E>) ImmutableCollections.EMPTY_LIST;
return list;
case 1:
return new ImmutableCollections.List12<>(elements[0]);